package com.boot.study.user.controller;

import com.boot.study.common.Result;
import com.boot.study.user.dto.RegisterUserRequest;
import com.boot.study.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("index")
    public Result index() {
        Result welcome = userService.welcome();
        return welcome;
    }

    @RequestMapping("user/register")
    public Result register(@RequestBody @Valid RegisterUserRequest userRequest) {
        Result result = userService.registerUser(userRequest);
        return result;
    }

}
